﻿package mortal.game.view.common
{
    import com.gengine.global.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.font.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.mvc.core.*;

    public class LeftTimeView extends View
    {
        private var _parse:String;
        private var _tfLeftTime:SecTimerView;

        public function LeftTimeView(param1:String = "mm:ss")
        {
            this._parse = param1;
            this.layer = LayerManager.msgTipLayer;
            this.stageResize();
            return;
        }// end function

        public function setParse(param1:String = "mm:ss") : void
        {
            this._parse = param1;
            this._tfLeftTime.setParse(this._parse);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = false;
            this.mouseChildren = false;
            var _loc_1:* = new GTextFormat(FontUtil.songtiName, 16, 16580352);
            _loc_1.align = TextFormatAlign.RIGHT;
            _loc_1.bold = true;
            this._tfLeftTime = UIFactory.secTimeView(this._parse, -300, 0, 300, 22, this, _loc_1);
            this._tfLeftTime.timeOutHandler = this.removeSelf;
            return;
        }// end function

        protected function removeSelf() : void
        {
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tfLeftTime.dispose(param1);
            this._tfLeftTime = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateLeftTime(param1:int) : void
        {
            if (this._tfLeftTime)
            {
                this._tfLeftTime.setLeftTime(param1);
            }
            return;
        }// end function

        public function get tfLeftTime() : SecTimerView
        {
            return this._tfLeftTime;
        }// end function

        public function get leftTime() : int
        {
            var _loc_1:int = 0;
            if (this._tfLeftTime)
            {
                _loc_1 = this._tfLeftTime.getLeftTime();
            }
            return _loc_1;
        }// end function

        override public function stageResize() : void
        {
            this.x = Global.stage.stageWidth - 380;
            this.y = 100;
            return;
        }// end function

        public function setCenterPosition() : void
        {
            this.x = Global.stage.stageWidth / 2 + 100;
            this.y = Global.stage.stageHeight / 2 - 120;
            return;
        }// end function

        public function setBottomPosition() : void
        {
            this.x = Global.stage.stageWidth / 2 + 100;
            this.y = Global.stage.stageHeight / 2 + (Global.stage.stageHeight / 2 - this._tfLeftTime.textHeight) / 2 + this._tfLeftTime.textHeight;
            return;
        }// end function

        public function setSceneTextStyle() : void
        {
            this._tfLeftTime.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 32, 16777215, null, null, null, null, TextFormatAlign.LEFT);
            this._tfLeftTime.filters = [FilterConst.taskShowTargetFilter];
            this._tfLeftTime.selectable = false;
            this._tfLeftTime.mouseEnabled = false;
            this._tfLeftTime.width = 400;
            this._tfLeftTime.height = 100;
            this._tfLeftTime.alpha = 1;
            return;
        }// end function

        public function get running() : Boolean
        {
            if (this._tfLeftTime)
            {
                return this._tfLeftTime.running;
            }
            return false;
        }// end function

    }
}
